<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>百度一下</button>
  <button class="close">关闭窗口</button>
  <script>

    // window:https://developer.mozilla.org/zh-CN/docs/Web/API/Window
    // ECMAScript规范:全局对象->globalThis
    // 对于浏览器 -> window
    // 对于Node -> global
    console.log(window.console, window.alert)
    console.log(window)
    console.log(globalThis)
    console.log(window === globalThis)

    // 浏览器窗口
    console.log(window.outerHeight)

    // 补充的方法
    var openBtnEl = document.querySelector("button")
    var closeBtnEl = document.querySelector(".close")
    openBtnEl.onclick = () => {
      window.open("./page/new.html", '_blank')
    }
    closeBtnEl.onclick = () => {
      window.close()
    }

    // 常见的事件
    window.onfocus = function(){
      console.log("窗口获取到焦点")
    }
    window.onblur=function(){
      console.log("窗口失去了焦点")
    }

    window.onhashchange = function(){
      console.log("哈希值发生改变")
    }
  </script>
</body>

</html>